<script type="text/javascript" src="{{base_url("script/admin-planners/deal/01_deal_function.js")}}"></script>
<div id="tab">
    <ul style="margin-left: 30px;">
        <li class=""><span>Thông tin cơ bản<span></li>
        
        <li>Đặc điểm nổi bật</li>
        <li>Mô tả</li>
        <li>Album hình</li>
        <li>Hướng Dẫn</li>
    </ul>
    <div class="tab-thong-tin-co-ban">
        <div style="padding: 20px;width: 876px">
            <div>
        <table style="width:874px;padding-right: 2px;" class="">
            <tbody>
            <tr>
                <td style="">
                    <div class="_input-label">
                        <div class="input">
                            <input type="text" id="txt_deal_name" placeholder="" value="{{$configs["obj"]['name']}}">
                            <input type="hidden" id="txt_deal_id" placeholder="" value="{{$configs["obj"]['id']}}">
                            <div class="label eb"><label>Tên Deal <font color="red">-</font></label></div>
                        </div>
                    </div>
                </td>
                <td class="space"></td>
                <td>
                    <div class="_input-label">
                        <div class="input">
                            <input type="text" id="txt_deal_amount" placeholder="" value="{{$configs["obj"]['amount']}}">
                            <div class="label eb"><label>Số lượng <font color="red">-</font></label></div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td style="" colspan="3">
                    <div class="_input-label">
                        <div class="input">
        <!--                    <input type="text" id="txt_deal_url" placeholder="" value="" disabled="1">-->
        <div   style="position: absolute;
        top: 0;
        left: 0;
        right: 0;
        padding: 0;
        margin: 0;
        padding-left: 108px;
        width: 100%;
        border: 1px solid #CCC;
        height: 26px;
        line-height: 26px;
        background: #FAFAFA;"><span>{{base_url("deal")}}</span>/<span id="txt_deal_alias">{{$configs["obj"]['alias']}}</span></div>
                            <div class="label eb"><label>Alias <font color="red">-</font></label></div>
                        </div>
                    </div>
                </td>

            </tr>
            <tr>
                <td colspan="3">
                    <div class="_input-label">
                        <div class="input">
                            <input type="text" id="txt_deal_title" placeholder="" value="{{$configs["obj"]['title']}}">
                            <div class="label eb"><label>Tiêu đề <font color="red">-</font></label></div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td style="position: relative" colspan="3">
                    <div class="_input-label">
                        <div class="input">
                            <input type="text" id="txt_deal_image" placeholder="" value="{{$configs["obj"]['image']}}">
                            <div class="label eb"><label>Hình Ảnh <font color="red">-</font></label></div>
                        </div>
                        <div class="icon16 hover50 tooltip" style="position: absolute;top:10px;right:8px;cursor: pointer" 
                            onclick="BrowseServer( 'Images:/', 'txt_deal_image' );" title="Chọn hình ảnh">
                            <img src="{{base_url()}}images/icon/16/folder_explore.png">
                        </div>
                    </div>
                </td>
<!--                <td class="space"></td>
                <td style="position: relative">
                    <div class="_input-label" type="select">
                    <div class="input" type="select">
                        <div class="select">
                            <select id="cbx_deal_category">
                                <option value="HTML5 Template">Danh mục</option>

                            </select>
                        </div>
                        <div class="label eb"><label>Danh Mục</label></div>
                    </div>
                    </div>
                </td>-->
            </tr>
            <tr>
                <td colspan="3">
                    <input type="hidden" id="txt_deal_region" value="{{$configs["obj"]['region']}}"/>
                    <div class="jqx_group id-group-region">
                        <div class=""><span class="pl0 pr0 pt0 pb0 ml0 mr0 mt0 mb0">Khu Vực <font color="red">-</font></span></div>
                        <div>
                            {{if is_array($configs["region_list"]) and count($configs["region_list"])>0}}
                                {{foreach $configs["region_list"] as $re}}
                                <div style="display: inline-block;float: left">
                                    <div style="margin-top: 10px;" class='jqx_chbre re{{$re["id"]}}'>
                                        <span class="value">{{$re["name"]}}</span></div>
                                </div>
                                {{/foreach}}
                            {{else}}
                                No data to display.
                            {{/if}}
                            <div class="clear"></div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <input type="hidden" id="txt_deal_category" value="{{$configs["obj"]['category']}}"/>
                    <div class="jqx_group id-group-category">
                        <div class=""><span class="pl0 pr0 pt0 pb0 ml0 mr0 mt0 mb0">Danh Mục <font color="red">-</font></span></div>
                        <div>
                            {{if is_array($configs["category_list"]) and count($configs["category_list"])>0}}
                                {{foreach $configs["category_list"] as $ca}}
                                <div style="display: inline-block;float: left">
                                    <div style="margin-top: 10px;" class='jqx_chbca ca{{$ca["id"]}}'>
                                        <span class="value">{{$ca["name"]}}</span></div>
                                </div>
                                {{/foreach}}
                            {{else}}
                                No data to display.
                            {{/if}}
                            <div class="clear"></div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td style="">
                    <div class="_input-label">
                        <div class="input">
                            <input type="text" id="txt_deal_price" placeholder="" value="{{$configs["obj"]['price']}}">
                            <div class="label eb"><label>Giá Gốc <font color="red">-</font></label></div>
                        </div>
                    </div>
                </td>
                <td class="space"></td>
                <td>
                    <div class="_input-label">
                        <div class="input">
                            <input type="text" id="txt_deal_sale" placeholder="" value="{{$configs["obj"]['sale']}}">
                            <div class="label eb"><label>Giá Bán <font color="red">-</font></label></div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td style="">
                    <div class="_input-label">
                        <div class="input">
                            <input type="text" id="txt_deal_start_date" placeholder="" value="{{if isset($configs["obj"]['startdate'])}}{{date("Y-m-d H:i", strtotime($configs["obj"]['startdate']))}}{{/if}}">
                            <div class="label eb"><label>Ngày Bắt Đầu <font color="red">-</font></label></div>
                        </div>
                    </div>
                </td>
                <td class="space"></td>
                <td>
                    <div class="_input-label">
                        <div class="input">
                            <input type="text" id="txt_deal_end_date" placeholder="" value="{{if isset($configs["obj"]['enddate'])}}{{date("Y-m-d H:i", strtotime($configs["obj"]['enddate']))}}{{/if}}">
                            <div class="label eb"><label>Ngày Kết Thúc <font color="red">-</font></label></div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td style="">
                    <div class="_input-label" type="select">
                        <div class="input" type="select">
                            <div class="select">
                                <select id="cbx_deal_label">
                                    <option value="">[---Để Trống---]</option>
                                    <option value="new"{{if $configs["obj"]['label']=="new"}}selected=1{{/if}}>Mới</option>
                                    <option value="buy"{{if $configs["obj"]['label']=="buy"}}selected=1{{/if}}>Mua Nhiều</option>
                                    <option value="hot"{{if $configs["obj"]['label']=="hot"}}selected=1{{/if}}>Nổi Bật</option>
                                    <option value="discount"{{if $configs["obj"]['label']=="discount"}}selected=1{{/if}}>Giảm Giá</option>
                                    

                                </select>
                            </div>
                            <div class="label eb"><label>Nhãn</label></div>
                        </div>
                    </div>
                </td>
                <td class="space"></td>
                <td>
                    
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <div class="input-full">
                        <div class="label eb"><label>Tag</label></div>
                    </div>
                    <div style="padding:27px 10px 0 0;">
                        <textarea class="_s _w100" id="txt_deal_tag" rows="3" cols="103" 
                                style="width: 100%;height: 32px;padding-left: 8px">{{$configs["obj"]['tag']}}</textarea>
                    </div>

                </td>
            </tr>
            <tr>
                <td colspan="3" style="">
                    <span style="color: blue">Thêm lúc : {{$configs["obj"]['insert']}}</span>
                </td>
            </tr>
        </tbody>
        </table>
            </div>
        </div>
        
    </div>
    <div class="tab-dac-diem-noi-bat">
        <div style="padding: 20px;width: 876px">
            <div>
                <table style="width:874px;padding-right: 2px;" class="">
                    <tbody>
                        <tr>
                            <td colspan="3">
                                <div class="input-full">
                                    <div class="label eb"><label>Nội dung ngắn gọn</label></div>
                                </div>
                                <div style="padding:27px 10px 0 0;">
                                    <textarea class="_s _w100" id="txt_deal_brief" rows="3" cols="103" 
                                            style="width: 100%;height: 100px;padding-left: 8px">{{$configs["obj"]['brief']}}</textarea>
                                </div>

                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">


                                <div class="input-full">
                                    <div class="label eb"><label>Đặc điểm nổi bật <font color="red">-</font></label></div>
                                </div>
                                <div style="padding:27px 0px 0 0;width: 870px">
                                    <textarea class="_s _w100 mceNoEditor" id="txt_deal_ddnb" rows="3" cols="103" 
                                            style="width: 862px; height: 200px;padding-left: 8px" aria-hidden="true">{{$configs["obj"]['ddnb']}}</textarea>
                                </div>

                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>

    </div>
    <div class="tab-noi-dung">
        <div style="padding: 20px;width: 876px">
            <div>
                <table style="width:874px;padding-right: 2px;" class="">
                    <tbody>
                        <tr>
                            <td colspan="3">


                                <div class="input-full">
                                    <div class="label eb"><label>Nội dung <font color="red">-</font></label></div>
                                </div>
                                <div style="padding:27px 10px 0 0;width: 870px">
                                    <textarea class="_s _w100 mceEditor" id="txt_deal_content" rows="3" cols="103" 
                                            style="width: 820px; height: 200px;padding-left: 8px" aria-hidden="true">{{$configs["obj"]['content']}}</textarea>
                                </div>

                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    
    <div class="tab-album-hinh">
        <div style="padding: 20px;width: 876px">
            <div>
                <div id="txt_deal_album" class="hidden">{{$configs["obj"]['album']}}</div>
                <table style="width:874px;padding-right: 2px;" class="">
                    
                        <tr>
                            <th>Hình ảnh</th>
                            <th>Đường Dẫn</th>
                            <th style="width: 120px">#</th>
                        </tr>
                        <tbody id="deal-auto-album">
                            {{if $configs["obj"]["stralbums"]==""}}
                            <tr>
                                <td colspan="3">Hiện chưa tạo album hình.</td>
                            </tr>
                            {{else}}
                            {{$configs["obj"]["stralbums"]}}
                            {{/if}}
                        </tbody>
                        <tr style="background-color: #fffafc">
                                <td colspan="3">Thêm hình vào album ảnh của deal</td>
                        </tr>
                        <tr style="background-color: #fffafc">
                            <td style="position: relative" colspan="2">
                                <div class="_input-label">
                                    <div class="input">
                                        <input type="text" id="txt_deal_add_album_image" placeholder="" value="">
                                        <div class="label eb"><label>Hình Ảnh</label></div>
                                    </div>
                                    <div class="icon16 hover50 tooltip" style="position: absolute;top:10px;right:8px;cursor: pointer" 
                                        onclick="BrowseServer( 'Images:/', 'txt_deal_add_album_image' );" title="Chọn hình ảnh">
                                        <img src="{{base_url()}}images/icon/16/folder_explore.png">
                                    </div>
                                </div>
                            </td>
                            <td>
                                <input type="button" class="classic-btn" value="Thêm"
                                       onclick="addAlbum();"
                                       />
                            </td>
                        </tr>
                        <tr style="background-color: #fafafc">
                            <td style="position: relative" colspan="3">
                                <input type="button" class="classic-btn" 
                                       value="Tự động lấy các hình từ nội dung của deal."
                                       onclick="AutoGenAlbum();"
                                       />
                            </td>
                        </tr>
                    
                </table>
            </div>
        </div>

    </div>
    <div>
        Hướng Dẫn.<br/>
        Phần này sẽ được cập nhật sau.

    </div>
</div>
<div class="pt8 pb8" id="btn-deal-groupbutton">
    <input type="button" class="classic-btn pl20 pr20"  id="btn-deal-ok"
        style="width: auto;padding-left: 20px;padding-right: 20px"
        value="Kiểm Tra"
        onclick="CheckDeal();"
        />
    <input type="button" class="classic-btn pl20 pr20"  id="btn-deal-ok"
        style="width: auto;padding-left: 20px;padding-right: 20px"
        value="Lưu."
        onclick="DealOk();"
        />
    <input type="button" class="classic-btn pl20 pr20" id="btn-deal-cancel"
        style="width: auto;padding-left: 20px;padding-right: 20px"
        value="Hủy."
        onclick="DealCancel();"
        />
</div>
<div style="color: red;text-align: center" id="deal-loadding" class="pt8 pb8 hidden">Đang xử lý...</div>
 <script type="text/javascript">
     var regions= {{json_encode($configs["region_list"])}};
 
     function getRekey(name){
        for(var i=0;i<regions.length;i++){
            if(regions[i].name==name)
                return regions[i].id;
        }
        return 0;
     }
     
     var categorys= {{json_encode($configs["category_list"])}};
 
     function getCakey(name){
        for(var i=0;i<categorys.length;i++){
            if( categorys[i].name==name){
                return categorys[i].id;
            }
            //$("#txt_deal_brief").val(categorys[3].name)
        }
        return 0;
     }
     function CreateElements(){
        var theme = 'classic';
        $(".jqx_group").jqxExpander({ showArrow: false, toggleMode: 'none', theme: theme });
        $('#tab').jqxTabs({ width:920, theme: theme });
        
        //create group checkbox authority
        // {{if is_array($configs["region_list"]) and count($configs["region_list"])>0}}
        // {{foreach $configs["region_list"] as $re}}

        $('.jqx_chbre.re{{$re["id"]}}').jqxCheckBox({ 
            checked: {{$re["checked"]}},
            height: 25,width: '120px', theme:theme });
        // {{/foreach}}
        // {{/if}}
        
        //create group checkbox authority
        // {{if is_array($configs["category_list"]) and count($configs["category_list"])>0}}
        // {{foreach $configs["category_list"] as $ca}}

        $('.jqx_chbca.ca{{$ca["id"]}}').jqxCheckBox({ 
            checked: {{$ca["checked"]}},
            height: 25,width: '120px', theme:theme });
        // {{/foreach}}
        // {{/if}}
        
    }
    var k;
    $(document).ready(function () {
        CreateDatetimeElement();
        CreateElements();
        CreateEditorElement();
        AddHandleEvents();
    });
</script>